package com.lovo.csc.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lovo.csc.entity.Deposit;
import com.lovo.csc.entity.Prepay;
import com.lovo.csc.service.IDepositService;
import com.lovo.csc.service.IPrepayService;
import com.lovo.remoteservice.IPayService;
import com.lovo.util.Verifier;
import com.lovo.vo.TopUpVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 用户预存款 前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-07-07
 */
@RestController
@RequestMapping("/prepay")
@Api(tags = "预存款操作层 文林挥  002")
public class PrepayController {
    @Autowired
    IPrepayService service;
    @Autowired
    IDepositService depositService;
    @Autowired
    IPayService payService;
    @ApiOperation(value = "分页查看所有会员用户")
    @GetMapping("findMembership")
    public IPage findMembership(int currentPage,int PageSize){
        IPage<Prepay> page = new Page<>();
        page.setCurrent(currentPage);
        page.setSize(PageSize);
        return service.page(page,null);
    }

    @ApiOperation(value = "用户预存款的充值记录")
    @GetMapping("findDepositRecords")
    public List<Deposit> findDepositHistory(String userCode){
        QueryWrapper<Deposit> qw=new QueryWrapper<>();
        qw.eq("user_code",userCode);
        return depositService.list(qw);
    }


    @ApiOperation(value = "消费接口调用")
    @GetMapping("pay")
    public boolean payMoney( String userCode,float money,String goodsInfo){
       return payService.consumption(userCode,money,goodsInfo);
    }

    @ApiOperation(value = "获取token")
    @GetMapping("getToken")
    public String getToken(String userCode,double money){
        return payService.tokenInfo(userCode,money);
    }

}
